package com.wnxy.jdk8;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntBinaryOperator;
import java.util.function.IntPredicate;
import java.util.function.Supplier;

public class App2 {
    public static void main(String[] args) {
        t4();
    }
    public static void t4() {
        String result = typeConvert(num->String.valueOf(num));
        System.out.println("result = " + result);
    }

    private static String typeConvert(Function<Integer,String> function) {
        String apply = function.apply(100);
        return apply;
    }


    public static void t3() {
        printNum(num -> num % 2 ==0);
    }

    private static void printNum(IntPredicate intPredicate) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        for (int i = 0; i < arr.length; i++) {
            if (intPredicate.test(arr[i])){
                System.out.println(arr[i]);
            }
        }
    }

    private static void t2() {
        int calculate = calculate((left, right) -> left * right);
        System.out.println("calculate = " + calculate);
    }

    private static int calculate(IntBinaryOperator op) {
        int result = op.applyAsInt(10, 10);
        return result;
    }

    private static void t1() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
            }
        }).start();

        new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        }).start();
    }

}



















